<?php
session_start();

include_once ("connexion.php");

$query_pays = "SELECT * FROM pays";
$Pays = mysqli_query($bdd,$query_pays);

$query_villes = "SELECT * FROM villes";
$Ville = mysqli_query($bdd,$query_villes);

$query_types = "SELECT * FROM type_bien";
$Type = mysqli_query($bdd,$query_types);
$erreur = "";

if(isset($_POST["submit"])){
 $ville = $_POST['ville'];
 $pays = $_POST['pays'];
 $type = $_POST['type'];
 $tarifjour = $_POST['tarifjour'];
 $tarifsemaine = $_POST['tarifsemaine'];
 $surface = $_POST['surface'];
 
 
        $recherche ="SELECT * FROM biens  WHERE id_ville = ".$ville." AND id_pays = ".$pays." AND id_type = ".$type." AND tarif_jour = ".$tarifjour." AND tarif_semaine = ".$tarifsemaine." AND surface = ".$surface."";
    
	$resultat = mysqli_query($bdd,$recherche);
    
    if ($resultat == false) {
        
     echo "Nous ne pouvons pas trouver un logement avec vos critère de recherches !";
	 
    }
    
    if($resultat == true){
        echo "Voici le résultat de votre recherche";
        echo "<table border= 1 >";
        echo "<tr><td>Ville</td></tr></td></tr><tr><td>Pays</td></tr><tr><td>Type</td></tr><tr><td>Tarif jour</td></tr><tr><td>Tarif semaine</td></tr><tr><td>Surface</td></tr>";
        while ($recherche = mysqli_fetch_array ($resultat))
        {
			echo $recherche["id_ville"];
            echo $recherche["id_pays"];
            echo $recherche["id_type"];
            echo $recherche["tarif_jour"];
            echo $recherche["tarif_semaine"];
			echo $recherche["surface"];
        }
        echo"</table>";
    }
    
}
include_once("accueil.html");

?>